package com.cuit.washneedshake.controller;

import cn.hutool.json.JSONUtil;
import com.cuit.washneedshake.common.BaseResponse;
import com.cuit.washneedshake.common.ErrorCode;
import com.cuit.washneedshake.model.dto.NationalNewTrendsResp;
import com.cuit.washneedshake.service.impl.NationalNewTrendsServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.LinkedList;

@RestController
@RequestMapping("/national-new-trends")
public class NationalNewTrendsController {
   @Resource
   NationalNewTrendsServiceImpl nationalNewTrendsService;


    @GetMapping("/getNewTrendsInfo")
    public BaseResponse<String> getNationalNewTrendsInfo() {

        LinkedList<NationalNewTrendsResp> nationalNewTrends = nationalNewTrendsService.getNationalNewTrendsInfo();
        if (nationalNewTrends == null) {
            return new BaseResponse<>(ErrorCode.NOT_FOUND_ERROR);
        }
        BaseResponse<String> baseResponse = new BaseResponse<>(ErrorCode.SUCCESS.getCode(), JSONUtil.toJsonStr(nationalNewTrends));
        return baseResponse;
    }

}




